package net.osin.playscalajs.TableControl

import com.thoughtworks.binding.Binding.{Var, Vars}
import org.scalajs.dom.raw.Event

class ConcreteTable2 extends TableTrait {
  override val headers: Vars[String] = Vars("java", "Python", "scala","C++")
  override val contents: Vars[Vars[Var[String]]] = Vars.empty[Vars[Var[String]]]
  override val totalCount: Int = 25

  override def generate(page_index: Int, page_size: Int): Unit =
  {
    val (star, end) = Util.pagination(page_index, page_size, totalCount)
    for (i <- Range(star, end + 1))
    {
      contents.value += Vars(Var("java" + i), Var("Python" + i), Var("scala" + i),Var("C++"+i))
    }
  }

  override def addRow(event: Event): Unit = contents.value += Vars(Var(" new java"), Var("new Python"),Var("new scala"), Var("new C++"))

}
